const http = require('http')
const serve = http.createServer((request,response) => { 
   // 实例化url对象
   // const url = new URL('/search?wd=hello&ie=utf-8', 'http://127.0.0.1:3000')
   const url = new URL(request.url,'http://127.0.0.1:3000')
   // console.log('url :>> ', url);
   // {
   //    href: 'http://127.0.0.1:3000/search?key=h5',
   //    origin: 'http://127.0.0.1:3000',
   //    protocol: 'http:',
   //    username: '',
   //    password: '',
   //    host: '127.0.0.1:3000',
   //    hostname: '127.0.0.1',
   //    port: '3000',
   //    pathname: '/search',
   //    search: '?key=h5',
   //    searchParams: URLSearchParams { 'key' => 'h5' },
   //    hash: ''
   //  }
   console.log('object :>> ', url.searchParams.get('key'));
   response.end('hello world')

 })
 serve.listen(3000,() => {
    console.log('服务启动成功...')
 })